package com.example.facecompare.user.userinfo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.facecompare.user.img.entity.UserImg;
import com.example.facecompare.user.img.mapper.UserImgMapper;
import com.example.facecompare.user.userinfo.entity.User;
import com.example.facecompare.user.userinfo.entity.UserAndImg;
import com.example.facecompare.user.userinfo.mapper.UserMapper;
import com.example.facecompare.user.userinfo.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tbb
 * @since 2023-07-31
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserImgMapper userImgMapper;

    @Autowired
    private UserMapper userMapper;

    @Transactional
    public void transferUserImg(UserAndImg userAndImg){

        userMapper.insert(userAndImg.getUser());

    }

    @Transactional
    public UserImg transferImgPath(User user){

//        iUserService.saveOrUpdate(user);
        User user1 =  userMapper.selectById(user.getOpenid());
        if (user1!=null){
            userMapper.updateById(user);
        }else {
            userMapper.insert(user);
        }
        System.out.println(user.toString());
        return userImgMapper.selectById(user.getIid());
    }
}
